const prompt = require('prompts');
let public = require('./public/public')//导入公共package
module.exports = async (api, options, rootOptions) => {
  // 修改 `package.json` 里的字段
  let response,publicResponse
  publicResponse = await prompt(require('./public/prompts'))
  if (options.selectTemplate == 'uni-template') {
    response = await prompt(require('./uni-template/prompts'));
    if (response.elementUI == '是') {
      api.extendPackage({
        devDependencies: {
          "element-ui": "^2.13.0"
        }
      })
    }
    // console.log(response.color);
    // 复制并用 ejs 渲染 `./template` 内所有的文件
    api.render('../template/uni-template')
    api.extendPackage(require('./uni-template/uni-template'))
  }
  if (options.selectTemplate == 'fant-pc') {
    response = await prompt(require('./fant-pc/prompts'));
    if (response.elementUI == '是') {
      api.extendPackage({
        devDependencies: {
          "element-ui": "^2.13.0"
        }
      })
    }
    api.render('../template/fant-pc')
    api.extendPackage(require('./fant-pc/fant-pc'))
  }
  if (options.selectTemplate == 'uni-test') {
    response = await prompt(require('./uni-test/prompts'));
    api.render('../template/uni-test')
    api.extendPackage(require('./uni-test/uni-test'))
  }
 
  // end all if
  options.response = response //template里只能拿到options,所以要把response挂载到options
  api.extendPackage(public)//导入公共package
}